package ms.unicorn.language.languagedef;

import ms.unicorn.modellanguage.LanguageElement;

import org.eclipse.emf.common.util.EList;

public class RelationDefUtil {

	public static RelationConstraint resolveConstraint(LanguageElement src, 
			LanguageElement tar, EList<RelationConstraint> constraints) {
		RelationConstraint constraint = null;
		for(RelationConstraint rc: constraints) {
			if (rc.getSources().contains(src.getDefinition()) && rc.getTargets().contains(tar.getDefinition()) 
					&& (constraint == null || rc.isForbidden())) {
				constraint = rc;
				if (rc.isForbidden())
					break;
			}
		}
		return constraint;
	}
	
}
